<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>map</title>
	</head>

	<body>
		<script src="lib/topo.js"></script>
		<script type="text/javascript" src="lib/d3.min.js"></script>
		<script type="text/javascript">
			var width = 1000;
			var height = 1000;

			var svg = d3.select("body").append("svg")
				.attr("width", width)
				.attr("height", height)
				.append("g")
				.attr("transform", "translate(0,0)");

			var projection = d3.geo.mercator()
				.center([107, 31])
				.scale(850)
				.translate([width / 2, height / 2]);

			var path = d3.geo.path()
				.projection(projection);

			var color = d3.scale.category20();

			d3.json("./lib/china.topojson", function(error, root) {

				if(error){
					return console.error(error);
				}
				var georoot = topojson.feature(toporoot,toporoot.objects.china)
					
				svg.selectAll("path")
					.data(georoot.features)
					.enter()
					.append("path")
					.attr("stroke", "#000")
					.attr("stroke-width", 1)
					.attr("fill", function(d, i) {
						return color(i);
					})
					.attr("d", path)
					.on("mouseover", function(d, i) {
						d3.select(this)
							.attr("fill", "yellow");
					})
					.on("mouseout", function(d, i) {
						d3.select(this)
							.attr("fill", color(i));
					});

			});
		</script>
	</body>

</html>